//
//  BaseShareAction.m
//  NetEaseFinancial
//
//  Created by 吴玉峰 on 8/26/15.
//  Copyright (c) 2015 吴玉峰. All rights reserved.
//

#import "WYFBaseShareAction.h"

#import "WYFJSCommand.h"
#import "TalkingData.h"

 static NSString* const KEY_SOURCE_TYPE = @"sourceType";

@implementation WYFBaseShareAction

- (NSString*)getIconName {
    NSLog(@"Error:should use subclass implement of getIconName");
    return nil;
}

- (NSString*)getLabelName {
    NSLog(@"Error:should use subclass implement of getLabelName");
    return nil;
}

- (BOOL) shareWithHolder:(WYFShareHolder*) holder {
    NSString* label = [[self getLabelName] stringByReplacingOccurrencesOfString:@"\n" withString:@""];
    NSLog(@"label------------:%@", label);
    NSString* sourceType = holder.sourceType;
    if (sourceType == nil || sourceType.length == 0) {
        sourceType = label;
    }
    NSDictionary *params = @{KEY_SOURCE_TYPE:sourceType};
    // TODO 去除label中的换行符
    [TalkingData trackEvent:@"分享" label:label parameters:params];
    if (self.command != nil) {
        NSDictionary* result = @{@"result" : @"success"};
        [self.command setResultForJs:result];
        self.command = nil;
    }

    return NO;
}

@end
